import { ParamsType } from "@/api/constructor/project/types";
import request from "@/utils/request";
import { NewProjectManagerType, PayrollDetailForm, ProjectTeamForm } from "@/api/manager/project/types";


/**
 * 获取项目管理列表
 */
export function getProjectMagList(data: ParamsType) {
  return request({
    url: "/api/v1/constructor/project/project_page",
    method: "get",
    params: data,
  });
}

/**
 * 获取工资单列表
 */
export function getPayrollList(data: ParamsType) {
  return request({
    url: "/api/v1/constructor/wagepayroll/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取项目管理列表
 */
export function getProjectMagInfo(projectId: number) {
  return request({
    url: `api/v1/constructor/project/${projectId}/projectform`,
    method: "get",
  });
}

/**
 * 修改项目
 */
export function editProject(id: number, data: NewProjectManagerType) {
  return request({
    url: "/api/v1/constructor/project/update_project/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 工资单审核
 */
export function auditPayroll(id, data) {
  return request({
    url: "/api/v1/constructor/wagepayroll/audit/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 获取工资单明细详情信息
 */
export function getPayrollDetail(id: number) {
  return request({
    url: "/api/v1/constructor/wagepayrolldetail/" + id,
    method: "get",
  });
}

/**
 * 获取工资单审核记录
 */
export function getPayrollInfoAuditLogs(id: number) {
  return request({
    url: "/api/v1/constructor/wagepayroll/auditLogs?id=" + id,
    method: "get",
  });
}

/**
 * 获取指挥部列表
 */
export function getCommanderList(data: ParamsType) {
  return request({
    url: "/api/v1/constructor/commander/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取指挥部信息
 */
export function getCommanderInfo(commanderId: number) {
  return request({
    url: `api/v1/constructor/commander/${commanderId}/form`,
    method: "get",
  });
}

/**
 * 新增指挥部信息
 */
export function addCommander(data) {
  return request({
    url: "/api/v1/constructor/commander/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改指挥部信息
 */
export function editCommander(id: number, data) {
  return request({
    url: "/api/v1/constructor/commander/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除指挥部信息
 */
export function deleteCommander(id) {
  return request({
    url: "/api/v1/constructor/commander/" + id,
    method: "delete",
  });
}

/**
 * 重置密码指挥部信息
 */
export function resetPasswordCommander(id, data) {
  return request({
    url: `api/v1/constructor/commander/${id}/password`,
    method: "patch",
    params: data,
  });
}

/**
 *	根据指挥部id获取项目详情
 */
export function getProjectsByCommanderId(id) {
  return request({
    url: `/api/v1/constructor/commander/CommanderProjects/` + id,
    method: "get",
  });
}

/**
 *	根据指挥部id获取项目详情
 */
export function saveCommanderProject(id, data) {
  return request({
    url: `/api/v1/constructor/commander/saveCommanderProject/` + id,
    method: "post",
    data: data,
  });
}

/**
 * 获取专户列表
 */
export function getProjectAccountList(data: ParamsType) {
  return request({
    url: "/api/v1/constructor/projectspecialaccount/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取专户信息
 */
export function getProjectAccountInfo(id: number) {
  return request({
    url: `api/v1/constructor/projectspecialaccount/${id}/form`,
    method: "get",
  });
}

/**
 * 获取项目班组列表
 */
export function getProjectTeamList(data: ParamsType) {
  return request({
    url: "/api/v1/constructor/projectgroup/page",
    method: "get",
    params: data,
  });
}

/**
 * 根据班组ID 获取班组人员列表
 */
export function getProjectTeamMemberListByTeamId(id) {
  return request({
    url: "/api/v1/constructor/projectgroupmember/getProjectGroupMemberByGroupId/" + id,
    method: "get",
  });
}

/**
 * 获取项目班组下拉列表
 */
export function getProjectTeamPulldownList() {
  return request({
    url: "/api/v1/constructor/projectgroup/getProjectCorps",
    method: "get",
  });
}

/**
 * 获取班组信息
 */
export function getProjectTeamInfo(id: number) {
  return request({
    url: `api/v1/constructor/projectgroup/${id}/form`,
    method: "get",
  });
}

/**
 * 获取人员信息
 */
export function getPersonInfo(id: number) {
  return request({
    url: `api/v1/constructor/person/${id}/form`,
    method: "get",
  });
}
